<!DOCTYPE html>
<html xmlns=http://www.w3.org/1999/xhtml xmlns:bd=http://www.baidu.com/2010/xbdml>
<head>
    <meta charset="utf-8">
    <title>合同管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/staff/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="/staff/layout/css/font_eolqem241z66flxr.css" media="all" />
    <script type="text/javascript" src="/staff/layout/js/jquery.min.js"></script>
    <style type="text/css">
        th,td{
            text-align: center ! important;
        }
    </style>
</head>
<body class="childrenBody">
<blockquote class="layui-elem-quote news_search">
    <form class="layui-form" id="form" action="/admin/pact/index" method="get">
  
        <div class="layui-input-inline" style="margin-top: 5px; margin-right: 30px;">
            <label class="layui-form-label" style="padding: 0;width: 66px;height: 38px;background-color: #1aa094;text-align: center;line-height: 38px;border-radius: 2px;">合同编号</label>
            <input type="text"  value="" placeholder="请输入合同编号" class="layui-input search_input" style="width: 15em">
        </div>
        <div class="layui-input-inline" style="">
            <a class="layui-btn search_btn" style="margin-top: 5px;background-color: #1e9c05;" id="pact">查询</a>
              <a class="layui-btn linksAdd_btn" style="background-color:#161917;margin-top: 5px;">添加</a>
        </div>
    </form>
</blockquote>

<div class="layui-form links_list">
    <table class="layui-table">
        {{ csrf_field() }}
        <thead>
        <tr>
            <th>合同名称</th>
            <th>合同内容</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody class="news_content">
            @if(!empty($data))
            @foreach($data as $val)
                <tr id="pact_{{$val['id']}}">
                    <td style="color:#0064ff;">{{$val['htname']}}</td>
                    <td>点击 <span style="color:red;cursor:pointer;" class="read" pact="{{$val['id']}}">查看</span> 合同内容 </td>
                    <td>
                     <!-- <a class="layui-btn layui-btn-mini read" pact="{{$val['id']}}"><i class="iconfont icon-wenben "></i> 查看</a> -->
                      <a class="layui-btn layui-btn-danger layui-btn-mini links_del" data-id="1" onclick="delPact({{$val['id']}})" ><i class="layui-icon"></i> 删除</a>
                    </td>
                </tr>
                 @endforeach
        @endif
</tbody>
</table>
</div>
</body>
<script type="text/javascript" src="/pc/layout/js/jquery.min.js"></script>
<script type="text/javascript" src="/pc/layui/layui.js"></script>
<script type="text/javascript">
    layui.config({
        base : "js/"
    }).use(['form','layer','jquery','laypage','element','laydate'],function(){
        var laydate = layui.laydate;
        var element = layui.element();
        var form = layui.form(),
            layer = parent.layer === undefined ? layui.layer : parent.layer,
            laypage = layui.laypage,
            $ = layui.jquery;

    })
    
      $('#pact').click(function () {
                $('#form').submit();
            })
 
    $(".linksAdd_btn").click(function(){
        layui.layer.open({
            title : "添加合同",
            type : 2,
            content : "/admin/pact/create",
             area: ['45em', '45em'],
             
            success : function(layero, index){
                layui.layer.tips('点击此处返回区域列表', '.layui-layer-setwin .layui-layer-close', {
                    tips: 3
                });
                } 
            })
    })

        // 查看
            $("body").on("click",".read",function(){  
            var _this = $(this);
            var id = _this.attr('pact');
            layui.layer.open({
            title : "查看合同",
            type: 2, 
            content: '/admin/pact/read?id='+id, 
            area: ['50em', '50em']
                });      
            })


       function delPact(id){  //删除
        layer.confirm('确定删除此信息？',{icon:3, title:'提示信息'},function(index){
            $.ajax({
                url:'/admin/pact/delete',
                type:'post',
                async:false,
                data:{
                    "_token": $("input[name=_token]").val(),
                    'id':id
                },
                dataType:'json',
                success:function (data) {
                    if(data.status == 1){
                        $('#pact_'+id).remove();
                        layer.msg('删除成功！',{time:800});
                         // parent.location.reload();
                         layer.close(index);
                    }
                }
            })
            layer.close(index);
        });
    }
</script>
</html>